var dbDetails = require("./db-details");

var mysql = require("mysql2");
var express = require("express");
var bodyParser = require('body-parser');
var http = require('http');
/*
//建立与数据库的链接关系
var con = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "123456",
    database: "bookstore_db",
    port: "3306"

});


//对该链接关系进行链接，检查是否正常工作
con.connect(function(err) {
    if(err) throw err;
    console.log("successfully connected");
});
*/

module.exports = {
	getconnection: ()=>{
	return mysql.createConnection({
		host:dbDetails.host,
		user:dbDetails.user,
		password:dbDetails.password,
		database:dbDetails.database,
        port:dbDetails.port
	});
}
}